#include"common.hpp"
#include"log.hpp"
using namespace std;

int main()
{
    Log log(Onefile, "./");
    log(Info, "This is a test");

    // 打开管道
    int fd = open(FILE_NAME, O_WRONLY);
    if(fd < 0)
    {
        log(Fatal, "Open!");
        return -1;
    }

    // 开始通信
    while(true)
    {
        string s;
        cout << "Enter@ ";
        getline(cin, s);
        ssize_t n = write(fd, s.c_str(), s.size());
        if(n < 0)
        {
            log(Fatal, "Write!");
            return -1;
        }
        log(Info, s.c_str());
    }

    close(fd);
    return 0;
}
